#include <iostream>
#include <cmath>

using namespace std;

void pn(int n, int m) {
	static char a[]="0123456789ABCDEF";
	if(n>=m)
		pn(n/m, m);
	cout << a[n%m];
}

int main()
{
	int n,m;
	cin >> n >> m;
	pn(n,m);
	return 0;
}
